@import './variable.less';

.menu-item-text,
.submenu-title {
  font-weight: 600;
  user-select: none;
}

.ant-pro-card .main-menu-right-content {
  max-width: calc(100vw - @main-menu-width);
  margin-left: @main-menu-width;
}

.item-content-container {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
}

.menu-item-text {
  height: 20px;
  margin-left: 4px;
  overflow: hidden;
  color: @gray-800;
  font-size: 14px;
}

.home-main-menu-right-content {
  // min-width: calc(100vw - @main-menu-hover-width);
  // max-width: calc(100vw - @main-menu-hover-width);
  margin-left: 75px;

  // .page-contianer-without-sec-menu {
  //   margin-left: 10px;
  // }
}

// 零级导航
.main-menu-container {
  position: fixed;
  z-index: 20;
  height: 100vh;
  background-color: @white;
  border-right: 1px #d3d3d3 solid;

  &.home-menu-container {
    border: none;

    &:hover {
      box-shadow: none;
    }

    .menu-item {
      border-radius: @menu-item-border-radius;
    }
  }

  &:hover {
    border: none;
    box-shadow: @main-menu-box-shadow;

    .menu-item {
      border-radius: @menu-item-border-radius;

      &:hover {
        background-color: @gray-200;
      }

      &.active {
        width: 100%;
        background-color: @primary;
      }
    }
  }

  .menu {
    display: flex;
    flex-flow: column wrap;
    width: @main-menu-width;
    border-bottom: 0;
    transition: @main-menu-width-transition;

    .menu-item-container {
      min-height: 400px;
      // overflow-x: hidden;
      margin-top: 15px;
      overflow-y: auto;
      width: 100%;
    }

    .menu-item {
      padding: @menu-item-padding-y @menu-item-padding-x;
      cursor: pointer;
      transition: @menu-transition;

      .icon-container {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 35px;
        min-height: 35px;
        border-radius: 50%;
      }

      .main-icon {
        color: @gray-800;
        font-size: 24px;
      }

      &:hover {
        background-color: @gray-200;
        border-bottom: 0;
      }

      &.active {
        width: 100%;

        .icon-container {
          color: @white;
          background-color: @primary;
        }

        .main-icon {
          color: @white;
        }

        .menu-item-text {
          color: @white;
        }
      }
    }

    .main-menu-name {
      visibility: hidden;
    }

    &:hover,
    &.home-menu {
      width: @main-menu-hover-width;
      background-color: @white;

      .menu-item {
        &:hover {
          color: @white;
          background-color: @gray-200;
        }

        &.active {
          color: @white;
          background-color: @primary;
          border-radius: @menu-item-border-radius;
        }
      }

      .main-menu-name {
        visibility: visible;
      }
    }

    .bottom {
      position: absolute;
      bottom: 70px;
      width: 100%;
    }
  }
}

.menu-bottom-content {
  font-size: 12px;
  display: none;
  color: @gray-600;

  &::before {
    min-width: calc(@sec-menu-width - 20px);
    height: 1px;
    margin-bottom: 5px;
    margin-left: 10px;
    background-color: @gray-400;
    content: '';
  }
}

.fold-icon-container {
  position: fixed;
  top: 94vh;
  left: @main-menu-width;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 26px;
  background-color: @gray-300;
  border-radius: 0 10px 10px 0;
  cursor: pointer;
  transition: transform 0.25s ease-in-out;

  &.open {
    left: @sec-menu-width + @main-menu-width - 20px;
    background-color: transparent;
    transform: rotate(180deg);
  }

  .fold-icon {
    font-size: 14px;
  }
}

// 没有一级导航时的body自适应
.page-contianer-without-sec-menu {
  min-width: calc(100vw - @main-menu-width - @sec-menu-width);
  max-width: calc(100vw - @main-menu-width -20px);
  margin-left: @main-menu-width;
  overflow: hidden; // 防止滚动
}

.sec-menu-and-page-contianer {
  width: 100%;
  min-width: calc(100vw - @main-menu-width - 20px);
  max-width: calc(100vw - @main-menu-width);
  margin-left: @main-menu-width;
  overflow: hidden; // 防止滚动
  color: @black;
  // background-color: @gray-100; 无须设置否则会出现颜色断层

  .sec-menu-right-content {
    margin-left: calc(@sec-menu-width + 10px);
  }

  .sec-menu-content-without-menu {
    margin-left: 10px;
  }

  .sec-menu-container {
    position: fixed;
    top: 40px;
    z-index: 2;
    flex-grow: 0;
    height: 0;
    border: none;

    .menu-item-container {
      min-height: 400px;
      margin-top: 15px;
      overflow-y: auto;
    }

    .menu {
      display: flex;
      flex-flow: column nowrap;
      justify-content: space-between;

      .testing-icon {
        position: relative;
        top: 2px;
        left: 15px;
        user-select: none;
      }

      .menu-bottom-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 60px;
      }

      &:hover {
        visibility: visible;
      }

      .menu-item {
        min-width: @sec-menu-width;
        height: 36px;
        border-radius: @menu-item-border-radius;

        .item-link {
          display: block;
          width: 100%;
          height: 100%;
        }

        &.sec-menu-item:hover {
          background-color: @gray-200;
        }

        &.active {
          .main-menu-name {
            color: @primary;
          }

          .item-content-container {
            background-color: @light-select-primary;
            border-radius: @menu-item-border-radius;
          }
        }
      }
    }
  }
}

// subMenu样式
.menu {
  padding-left: 0;

  .submenu-item {
    height: auto !important;

    .submenu-border {
      max-width: calc(@sec-menu-width - 20px);
      height: 1px;
      margin-top: 5px;
      margin-left: 10px;
      background-color: @gray-400;
    }

    .submenu-title {
      position: relative;
      height: 36px;
      overflow: hidden;
      color: @gray-600;
      font-size: 14px;
      line-height: 36px;
      user-select: none;

      .submenu-title-text {
        position: relative;
        left: 15px;
      }

      .testing-icon {
        position: relative;
        top: 0;
        left: 20px;
        user-select: none;
      }

      .arrow-icon {
        position: absolute;
        top: 10px;
        right: 12px;
      }
    }

    .active {
      width: 100%;
      height: 36px;
      background-color: @light-select-primary !important;
    }

    .submenu {
      display: none;
      padding-left: 0;
      white-space: nowrap;
      list-style: none;
      transition: @menu-transition;

      .submenu .menu-item {
        padding-left: 34px;
      }

      .menu-item {
        width: 100%;
        max-width: @sec-menu-width;
        height: 36px;
        padding-left: 20px;
        border-radius: @menu-item-border-radius;
        cursor: pointer;
        transition: @menu-transition;

        &.active {
          .menu-item-text {
            color: @primary;
          }
        }

        &:hover {
          background-color: @gray-200;
        }
        // 三级导航的icon
        .arrow-icon {
          transform: rotate(0deg);
          transition: transform 0.25s ease-in-out;
        }

        &.opened .arrow-icon {
          transform: rotate(90deg);
        }
      }
    }

    .arrow-icon {
      z-index: 20;
      font-size: 10px;
      transform: rotate(0deg);
      transition: transform 0.25s ease-in-out;
    }

    &.opened .arrow-icon {
      transform: rotate(180deg);
    }
  }

  .submenu-item:last-child {
    .submenu-border {
      display: none;
    }
  }

  .sec-submenu-item {
    .submenu {
      position: relative;
      left: -20px;
      padding-left: 0;

      .menu-item {
        width: @sec-menu-width;

        .menu-item-text {
          padding-left: @menu-item-padding-x;
        }
      }
    }

    &:hover {
      background-color: transparent !important;
      border-radius: 0 !important;
    }

    .submenu-border {
      height: 0;
    }

    .submenu-title {
      .submenu-title-text {
        left: 20px;
      }

      .arrow-icon {
        position: relative;
        top: 5px;
        left: -85px;
      }
    }
  }
  // 同时有menu-opened 和 submenu就能显示
  .submenu.menu-opened {
    display: block;
  }

  .menu-item-text {
    margin-left: 10px;
    line-height: 20px;
  }
}
